<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDevicesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('devices', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('算力ID');
            $table->unsignedInteger('user_id')->comment('用户ID');
            $table->unsignedInteger('total')->nullable()->default(0)->comment('总算力');
            $table->unsignedInteger('use')->nullable()->default(0)->comment('已用算力');
            $table->unsignedDecimal('price', 20, 8)->comment('每T算力价格（USDT）');
            $table->unsignedDecimal('cost', 20, 8)->comment('租赁算力花费金额（USDT）');
            $table->timestamp('finish_at')->comment('到期时间，3年有效期');
            $table->unsignedTinyInteger('status')->default(1)->comment('矿机状态 0-已过期  1-进行中');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('devices');
    }
}
